<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            margin: 0;
            background-color: black;
            background-image: url("../x.jpg");
            background-size: 3399px,3006px;
            background-repeat: no-repeat;
        }

    </style>
</head>
<body>
<script src="jquery.min.js"></script>
<script>
    setInterval(function () {
        let img = $("<img src='snow.png'>")
        let size = parseInt(Math.random() * 21) + 20;
        img.css("width", size + "px");
        img.css("position", "absolute");

        //得到窗口的宽高
        let w = $(window).width();
        let h = $(window).height();
        //得到随机的left值 0-(窗口尺寸-雪花尺寸)
        let left = parseInt(Math.random() * (w - size));
        img.css("left", left + "px");
        $("body").append(img);

        //让雪花做往下移动的动画
        img.animate({"top": (h - size) + "px"}, size*100).fadeOut(1000,function () {
            img.remove();
        })


    }, 30)
</script>
</body>
</html>